package com.yunhe.abnormal.client.fallback;

import com.yunhe.abnormal.client.DeviceClient;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.base.PointDataTypeDTO;
import com.yunhe.common.model.device.Analog;
import com.yunhe.common.model.device.DeviceDTO;
import com.yunhe.common.model.device.EnergyUnitDTO;
import com.yunhe.common.model.model.AnalogRequestBody;
import com.yunhe.common.util.FallbackUtil;
import feign.hystrix.FallbackFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author liuronglei
 */
@Component
public class DeviceFallbackFactory implements FallbackFactory<DeviceClient> {
    @Override
    public DeviceClient create(Throwable arg0) {
        return new DeviceClient() {

            @Override
            public ResponseEntity<ResultObject<DeviceDTO>> getDeviceById(Long id) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<String>> getDevicePathTitleByDeviceId(Long id) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<List<DeviceDTO>>> searchDevice(Long deviceTypeId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<EnergyUnitDTO>> getEnergyUnitById(Long id) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<EnergyUnitDTO>> getEnergyUnitByDeviceId(Long deviceId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Analog>> getAnalogByPointNumber(Long pointNumber) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<List<Analog>>> getAnalogsByPointNumbers(List<Long> pointNumbers) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Analog>> getAnalogByDevAndTypeAndTerminal(Long deviceId, Long typeId, String typeName) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<List<Analog>>> getAnalogsByDevAndType(List<Long> deviceId, List<Long> typeId, List<String> typeName) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Analog>> createAlarmAnalog(Long objectId, Analog analog) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<List<Analog>>> getAnalogsByDevAndTypeForPost(List<String> typeName, AnalogRequestBody requestBody) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<PointDataTypeDTO>> getPointDataTypeById(Long id) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<List<PointDataTypeDTO>>> getPointDataTypeByPointNumbers(List<Long> pointNumbers) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<PointDataTypeDTO>> getPointDataTypeByName(String name) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<PointDataTypeDTO>> getPointDataTypeByTitle(String title) {
                return FallbackUtil.getDefaultFallBack();
            }
        };
    }
}
